// Agent server in project publicprintingwithjason

/* Initial beliefs and rules */

/* Initial goals */

/* Plans */

//this plan handles the customer request
//it will choose a printer that is ok
//and tell it to print for the customer
//also will let the customer know where to get the print
@pcreatejob[atomic]
+!createjob[source(S)] : true
  <-
  	.print("Processing print request from ", S);
  	?printer(P, ok);
  	.send(P, achieve, printfor(S));
  	.send(S, tell, getprintat(P)).
  
//if the server is not able to create the job, it will notify the customer
//about the error
-!createjob[source(S)] : true
	<-
	.send(S, tell, error).

//when a printer change its status the server will update its beliefs.
+printer(P,S)[source(P)] : true 
	<-
	-printer(P,S)[source(P)];
	-printer(P,_);
	+printer(P,S).